#include<iostream>
#include<map>
using namespace std;
int main(){
	int n;
	cin>>n;
	int maxid,maxscore=-1;
	map<int,int> m;
	for(int i=0;i<n;i++){
		int id,score;
		cin>>id>>score;
		m[id]+=score;	
	}
	for(auto it=m.begin();it!=m.end();it++)
		if(it->second>maxscore){
			maxid=it->first;
			maxscore=it->second;
		}
	cout<<maxid<<" "<<maxscore;
	return 0;
} 
